﻿<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src=max.src></script>
<script>
var oDlg;
var oHttp;
var sHtml;
var bOpened;
var winStatus;
var popWin;
function checkMC(){
	if(!sHtml){
		getMC();
		setTimeout('checkMC()',5000);
	}
}
function getMC(){
	oHttp=null;
	oHttp=external.max_activex(max_security_id, 'Microsoft.XMLHTTP');
	oHttp.open('GET', 'http://mindcity.sina.com.tw/east/MC-lunar/', true);
	oHttp.onreadystatechange = function(){
		if(oHttp.readyState=='4'){
			setMC(oHttp.responseText);
		}
	}
	oHttp.send('');
}
function setMC(x){
	var aImg=new Array('btn_bad.gif','btn_sui.gif','btn_avoid.gif');
	var sMax='&nbsp;运程提示：用';
	var aArray=new Array(' Maxthon ',' MT ','傲游','马桶');
	var nRdm=Math.round(Math.random()*(aArray.length-1));
	sMax+=aArray[nRdm];
	aArray=new Array('大吉大利','路路畅通','福星高照','事事如意','一路平安','节节领先','过关斩将','马到功成','所向无敌','快人一步','生意兴隆');
	nRdm=Math.round(Math.random()*(aArray.length-1));
	sMax+=aArray[nRdm];
//	var sSp='';
//	var nCnt=0;
//	while(nCnt<100){
//		sSp+='&nbsp;';
//		nCnt++;
//	}
	//sHtml='<html><head><title>今日黄历'+sSp+'</title>';
	sHtml='<html><head>';	
	//sHtml+='<script>function document.onkeydown(){if(event.keyCode==27) window.close()}<\/script>';
	sHtml+='<style>*{font:12px Tahoma; line-height:14px; color:#5b5b5b} body{margin:40px 5px 5px 5px; background:url("huangli_bg.gif"); overflow:hidden}</style>';
	sHtml+='</head><body>';
	var n=x.indexOf('<!--好日子Group start-->');
	if(n!=-1){
		x=x.substring(n+21);
	}
	n=x.indexOf('<!--好日子Group end-->');
	if(n!=-1){
		x=x.substring(0,n);
	}
	var aMD=x.match(/<h2>(.*?)<\/h2>/);
	if(aMD.length){
		var y=aMD[1];
		y=y.replace(/西元.*?星期.*?月.*?日/,winStatus);
		sHtml+='&nbsp;'+y+'<br><br><table>';
	}
	var aMC=x.match(/<div class="right">.*?<\/div>/g);
	if(aMC.length){
		for(var i=0;i<aMC.length; i++){
			sHtml+='<tr><td><img src="'+aImg[i]+'"></td><td>'+aMC[i].replace('<div class="right">','').replace('</div>','')+'</td></tr>';
		}
	}
	sHtml+='</table><br>';
	sHtml+=sMax;
	sHtml+='</body></html>';
	//document.getElementById('date').title='打开今日黄历';
	document.getElementById('date').style.cursor='hand';
}
function showMC(){
	//alert(sHtml);
	if(!popWin)
	{
		popWin=window.createPopup();
		popWin.document.write(sHtml);
	}
	
	var y=22;
	if(window.event.screenY >350)
	{
		y=-222;
	}
	popWin.show(0,y,350,220,document.getElementById('date'));
//	return;
//	if(!bOpened){
//		var sAtr='status:no; help:no; dialogWidth:350px; dialogHeight:220px';
//		if(navigator.userAgent.indexOf('MSIE 7')==-1) sAtr='status:no; help:no; dialogWidth:350px; dialogHeight:250px';
//		oDlg=external.max_modelessDialog(max_security_id, 'dialog.htm', window, sAtr, window).document;
//		oDlg.write(sHtml);
//		oDlg.close();
//		bOpened=true;
//		document.getElementById('date').title='关闭今日黄历'
//	}
//	else{
//		oDlg.write('<script>window.close()<\/script>');
//		oDlg.close();
//		bOpened=false;
//		document.getElementById('date').title='打开今日黄历';
//	}
}
</script>
<script language="Javascript">
//codes from "状态栏显示日期" plugin by "杂草"
function FormatY(Y)
{
    var sY1 = new Array("甲","乙","丙","丁","戊","己","庚","辛","壬","癸");
    var sY2 = new Array("子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥");
    var sY3 = new Array("鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪");
    Y -= 4;
    return "【" + sY3[Y%12] + "】" + sY1[Y%10] + sY2[Y%12] + "年";
}
function FormatM(M)
{
    var sM = new Array("正","二","三","四","五","六","七","八","九","十");
    if (M <= 10)
    {
        return sM[M-1] + "月";
    }
    if (M == 11)
        return "十一月";
    else
        return "十二月";
}
function FormatD(D)
{
    var sD1 = new Array("初","十","廿","三");
    var sD2 = new Array("一","二","三","四","五","六","七","八","九","十");
    if (D !=20 && D !=30)
    {
        D --;
        return sD1[Math.floor(D/10)] + sD2[D%10];
    }
    else
    {
        return sD1[D/10] + sD2[9];
    }
}
function FormatW(Y, M, D)
{
    var sD = new Array("日","一","二","三","四","五","六");
    var d = new Date(Y, M - 1, D).getDay();
    return "星期" + sD[d];
}
function FormatHD(Y, M, D)
{
    var sHD = new Array("","小寒","大寒","立春","雨水","惊蛰","春分","清明","谷雨","立夏","小满","芒种","夏至","小暑","大暑","立秋","处暑","白露","秋分","寒露","霜降","立冬","小雪","大雪","冬至");
    var sInfo = new Array(0,21208,42467,63836,85337,107014,128867,150921,173149,195551,218072,240693,263343,285989,308563,331033,353350,375494,397447,419210,440795,462224,483532,504758);
    var sM = (M - 1) * 2;
    var offDate = new Date( ( 31556925974.7*(Y-1900) + sInfo[sM]*60000  ) + Date.UTC(1900,0,6,2,5) );
    var sD = offDate.getUTCDate();
    if (D == sD)
    {
        return "〖" + sHD[sM] + "〗";
    }
    else
    {
        sM = (M - 1) * 2 + 1;
        offDate = new Date( ( 31556925974.7*(Y-1900) + sInfo[sM]*60000  ) + Date.UTC(1900,0,6,2,5) );
        sD = offDate.getUTCDate();

        if (D == sD)
            return "〖" + sHD[sM] + "〗";
        else
            return "";
    }
}
function FormatSF(M, D)
{
    var tmp = "";
    for (var i in gSolarFestival)
        if (gSolarFestival[i].match(/^(\d{2})(\d{2})\s(.+)$/))
            if ((Number(RegExp.$1) == M) && (Number(RegExp.$2) == D))
            {
                tmp = "『" + RegExp.$3 + "』";
                break;
            }
    return tmp;
}
function FormatWF(Y, M, D)
{
    var tmp = "";
    var tmp1;
    var tmp2;
    var tmp3;
    var firstWeek = new Date(Y, M - 1, 1).getDay();
    for (var i in gWeekFestival)
        if (gWeekFestival[i].match(/^(\d{2})(\d)(\d)\s(.+)$/))
            if (Number(RegExp.$1) == M)
            {
                tmp1 = Number(RegExp.$2);
                tmp2 = Number(RegExp.$3);
                tmp3 = ((firstWeek>tmp2) ? 7 : 0) + 7 * (tmp1 - 1) + tmp2 - firstWeek;
                if (tmp3 == D)
                {
                    tmp = "『" + RegExp.$4 + "』";
                    break;
                }
            }
    return tmp;
}
function FormatLF(M, D)
{
    var tmp = "";
    for (var i in gLunarFestival)
        if (gLunarFestival[i].match(/^(\d{2})(\d{2})\s(.+)$/))
            if ((Number(RegExp.$1) == M) && (Number(RegExp.$2) == D))
            {
                tmp = "『" + RegExp.$3 + "』";
                break;
            }
    return tmp;
}

var gLunarMonthDay = new Array
(
0X4ae0,0Xa570,0X5268,0Xd260,0Xd950,0X6aa8,0X56a0,0X9ad0,0X4ae8,0X4ae0,
0Xa4d8,0Xa4d0,0Xd250,0Xd548,0Xb550,0X56a0,0X96d0,0X95b0,0X49b8,0X49b0,
0Xa4b0,0Xb258,0X6a50,0X6d40,0Xada8,0X2b60,0X9570,0X4978,0X4970,0X64b0,
0Xd4a0,0Xea50,0X6d48,0X5ad0,0X2b60,0X9370,0X92e0,0Xc968,0Xc950,0Xd4a0,
0Xda50,0Xb550,0X56a0,0Xaad8,0X25d0,0X92d0,0Xc958,0Xa950,0Xb4a8,0X6ca0,
0Xb550,0X55a8,0X4da0,0Xa5b0,0X52b8,0X52b0,0Xa950,0Xe950,0X6aa0,0Xad50,
0Xab50,0X4b60,0Xa570,0Xa570,0X5260,0Xe930,0Xd950,0X5aa8,0X56a0,0X96d0,
0X4ae8,0X4ad0,0Xa4d0,0Xd268,0Xd250,0Xd528,0Xb540,0Xb6a0,0X96d0,0X95b0,
0X49b0,0Xa4b8,0Xa4b0,0Xb258,0X6a50,0X6d40,0Xada0,0Xab60,0X9370,0X4978,
0X4970,0X64b0,0X6a50,0Xea50,0X6b28,0X5ac0,0Xab60,0X9368,0X92e0,0Xc960,
0Xd4a8,0Xd4a0,0Xda50,0X5aa8,0X56a0,0Xaad8,0X25d0,0X92d0,0Xc958,0Xa950,
0Xb4a0,0Xb550,0Xb550,0X55a8,0X4ba0,0Xa5b0,0X52b8,0X52b0,0Xa930,0X74a8,
0X6aa0,0Xad50,0X4da8,0X4b60,0X9570,0Xa4e0,0Xd260,0Xe930,0Xd530,0X5aa0,
0X6b50,0X96d0,0X4ae8,0X4ad0,0Xa4d0,0Xd258,0Xd250,0Xd520,0Xdaa0,0Xb5a0,
0X56d0,0X4ad8,0X49b0,0Xa4b8,0Xa4b0,0Xaa50,0Xb528,0X6d20,0Xada0,0X55b0
);
var gLunarMonth = new Array
(
0X00,0X50,0X04,0X00,0X20,
0X60,0X05,0X00,0X20,0X70,
0X05,0X00,0X40,0X02,0X06,
0X00,0X50,0X03,0X07,0X00,
0X60,0X04,0X00,0X20,0X70,
0X05,0X00,0X30,0X80,0X06,
0X00,0X40,0X03,0X07,0X00,
0X50,0X04,0X08,0X00,0X60,
0X04,0X0a,0X00,0X60,0X05,
0X00,0X30,0X80,0X05,0X00,
0X40,0X02,0X07,0X00,0X50,
0X04,0X09,0X00,0X60,0X04,
0X00,0X20,0X60,0X05,0X00,
0X30,0Xb0,0X06,0X00,0X50,
0X02,0X07,0X00,0X50,0X03
);
var gSolarFestival = new Array
(
"0101 新年元旦",
"0202 世界湿地日",
"0207 国际声援南非日",
"0210 国际气象节",
"0214 情人节",
"0301 国际海豹日",
"0303 全国爱耳日",
"0308 国际妇女节",
"0312 植树节",
"0314 国际警察日",
"0315 国际消费者日",
"0317 中国国医节",
"0320 老老狼生日",
"0321 世界森林日",
"0321 世界儿歌日",
"0322 世界水日",
"0323 世界气象日",
"0324 世界防结核",
"0325 中小学安全日",
"0330 巴勒斯坦国土日",
"0401 愚人节",
"0407 世界卫生日",
"0422 世界地球日",
"0423 世界图书版权日",
"0424 亚非新闻工作者日",
"0501 国际劳动节",
"0504 五四青年节",
"0505 碘缺乏防治日",
"0508 世界红十字日",
"0512 国际护士节",
"0515 国际家庭日",
"0517 世界电信日",
"0518 国际博物馆日",
"0520 学生营养日",
"0523 国际牛奶日",
"0531 世界无烟日", 
"0601 国际儿童节",
"0605 世界环境日",
"0606 全国爱眼日",
"0617 防荒漠和干旱日",
"0623 国际奥林匹克日",
"0625 全国土地日",
"0626 国际禁毒日",
"0701 建党节",
"0702 国际体育记者日",
"0707 抗日战争纪念日",
"0711 世界人口日",
"0730 非洲妇女日",
"0801 中国建军节",
"0808 中国男子节(爸爸节)",
"0815 日本投降日",
"0908 国际扫盲日",
"0910 教师节",
"0914 世界清洁日",
"0916 国际臭氧日",
"0918 九·一八纪念",
"0920 国际爱牙日",
"0927 世界旅游日",
"1001 国庆节",
"1001 国际音乐日",
"1002 国际和平日",
"1004 世界动物日",
"1008 全国高血压日",
"1008 世界视觉日",
"1009 万国邮联日",
"1010 辛亥革命日",
"1013 世界保健日",
"1014 世界标准日",
"1015 国际盲人节",
"1016 世界粮食日",
"1017 世界消贫日",
"1022 世界医药日",
"1024 联合国日",
"1031 世界勤俭日",
"1107 十月革命日",
"1108 中国记者日",
"1109 全国消防日",
"1110 世界青年节",
"1111 国际科学与和平周",
"1112 孙中山诞辰",
"1114 世界糖尿病日",
"1117 世界学生节",
"1121 世界问候日",
"1129 国际声援巴日",
"1201 世界艾滋病日",
"1203 世界残疾人日",
"1205 国际经社发展日",
"1208 国际儿童电视日",
"1209 世界足球日",
"1210 世界人权日",
"1212 西安事变日",
"1213 南京大屠杀",
"1221 国际篮球日",
"1224 平安夜",
"1225 圣诞节",
"1229 国际生物多样日"
);
var gWeekFestival = new Array
(
"0520 母亲节",
"0530 助残日",
"0630 父亲节",
"0911 劳动节",
"0932 国际和平日",
"0940 国聋人节",
"0950 海事日",
"1144 感恩节"
);
var gLunarFestival = new Array
(
"0101 春节",
"0115 元宵节",
"0202 龙抬头",
"0323 妈祖生辰",
"0505 端午节",
"0707 七夕情人节",
"0815 中秋节",
"0909 重阳节",
"1208 腊八节",
"1223 小年"
);

function LunarDate(Y, M, D)
{
    var tmp;
    var Diff = CalcDateDiff(Y, M, D);

    if (Diff < 49)
    {
        sY = 1900;
        if (Diff < 19)
        {
            sM = 11;
            sD = 11 + Diff;
        }
        else
        {
            sM = 12;
            sD = Diff - 18;
        }
    }
    else
    {
        Diff -= 49;
        sY = 1901;
        sM = 1;
        sD = 1;
        tmp = LunarYearDays(sY);
        while (Diff >= tmp)
        {
            Diff -= tmp;
            tmp = LunarYearDays(++sY);
        }
        tmp = LunarMonthDays(sY, sM) % 256;
        while (Diff >= tmp)
        {
            Diff -= tmp;
            if (sM == GetLeapMonth(sY))
            {
                tmp = Math.floor(LunarMonthDays(sY, sM)/256);
                if (Diff < tmp) break;
                Diff -= tmp;
            }
            tmp = LunarMonthDays(sY,++sM) % 256;
        }
        sD += Diff;
    }
}
function CalcDateDiff(Y, M, D)
{
    monthday = new Array(0, 31, 59 ,90, 120, 151, 181, 212, 243, 273, 304, 334);
    Diff = (Y - 1901) * 365;
    Diff += Math.floor((Y-1)/4) - Math.floor(1900/4);
    Diff -= Math.floor((Y-1)/100) - Math.floor(1900/100);
    Diff += Math.floor((Y-1)/400) - Math.floor(1900/400);
    Diff += monthday[M-1] + (IsLeapYear(Y)&&M>2 ? 1: 0);
    Diff += D - 1;
    return Diff;
}
function LunarYearDays(Y)
{
    var days = 0;
    var tmp;
    for (var i = 1; i <= 12; i++)
    {
        tmp = LunarMonthDays(Y, i);
        days += Math.floor(tmp/256);
        days += tmp % 256;
    }
    return days;
}
function LunarMonthDays(Y, M)
{
    var height = 0;
    var low = 29;
    var iBit = 16 - M;
    var lY = GetLeapMonth(Y);
    if (lY && (M > lY)) iBit --;
    if (gLunarMonthDay[Y-1901] & (1<<iBit)) low++;
    if (M == lY)
        if (gLunarMonthDay[Y-1901] & (1<<(iBit-1)))
            height = 30;
        else
            height = 29;
    return height*256 + low;
}
function GetLeapMonth(Y)
{
    var flag = gLunarMonth[Math.floor((Y - 1901)/2)];
    return (Y - 1901)%2 ? flag&0x0f : flag >> 4;
}
function IsLeapYear(Y)
{
    return !(Y%4) && (Y%100) || !(Y%400);
}

var sY, sM, sD;
function init()
{
    var Today = new Date();
    var tY = Today.getFullYear();
    var tM = Today.getMonth() + 1;
    var tD = Today.getDate();
    var HD = FormatHD(tY, tM, tD);
    var SF = FormatSF(tM, tD);
    var WF = FormatWF(tY, tM, tD);
    LunarDate(tY, tM, tD);
    var LF = FormatLF(sM, sD);

    winStatus = "" //Today.toLocaleString().split(' ')[0] + " " + FormatW(tY, tM, tD) + " ";
    winStatus += FormatY(sY) + FormatM(sM) + FormatD(sD) + HD + SF + WF + LF;
    document.getElementById('date').innerText = FormatY(sY) + FormatM(sM) + FormatD(sD);
}

</script>
<style>
body{
	font: 11px Tahoma;
	margin-left: 0px;
	margin-top: 4px;
	margin-right: 0px;
	margin-bottom: 0px;
	cursor: default;
	text-align: center;
	overflow: hidden;
}
</style>
</head>
<body nowrap onload="init();setTimeout('checkMC()',1000)" onselectstart="return(false)" ondragstart="return(false)">
<div id=date onmouseenter="if(sHtml)showMC()" onmouseleave="if(popWin) popWin.hide();"  onclick="if(sHtml)showMC()"></div>
</body>
</html>